package logic

import (
	"context"
	"user_srv/user"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseShowLogic {
	return &HouseShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseShowLogic) HouseShow(req *types.HouseShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.UserSrv.HouseShow(l.ctx, &user.HouseShowRequest{HouseId: req.HouseId})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "房源详情成功",
		Data: map[string]interface{}{
			"HouseId":       show.HouseId,
			"HouseName":     show.HouseName,
			"HouseFloor":    show.HouseFloor,
			"HouseType":     show.HouseType,
			"Address":       show.Address,
			"HouseCover":    show.HouseCover,
			"Area":          show.Area,
			"Price":         show.Price,
			"HouseDescribe": show.HouseDescribe,
			"HouseStatus":   show.HouseStatus,
		},
	}, nil
}
